
PREFIX?=/usr
DESTDIR?=



all:
	mkdir -p ./build/qt_docs
	mkdir -p ./tools/Qt/documentation/ignore-docs/
	cp -rf ./docs/* ./tools/Qt/documentation/ignore-docs/
	cd ./tools/Qt/documentation       && qcollectiongenerator cpg.qhcp -o ../../../build/qt_docs/cpg.qhc
	cd ./tools/Qt/library-static      && qmake ./stlibcpg.pro          && make
	cd ./tools/Qt/library-dynamic     && qmake ./dynlibcpg.pro         && make
	cd ./tools/Qt/editor              && qmake ./CadPlayG.pro          && make
.PHONY : all
 

clean:
	-rm -rf ./build
	-rm -rf ./tools/Qt/documentation/ignore-docs
	-cd ./tools/Qt/documentation
	-cd ./tools/Qt/library-static      && make clean && rm Makefile*
	-cd ./tools/Qt/library-dynamic     && make clean && rm Makefile*
	-cd ./tools/Qt/editor              && make clean && rm Makefile*
.PHONY : clean


distclean: clean

.PHONY : distclean


install:
	mkdir -p $(DESTDIR)$(PREFIX)/bin
	mkdir -p $(DESTDIR)$(PREFIX)/lib
	mkdir -p $(DESTDIR)$(PREFIX)/share/doc/cad-play-ground
	install -m 0755 ./build/CadPlayG $(DESTDIR)$(PREFIX)/bin
	install -m 0755 ./build/libcpg.* $(DESTDIR)$(PREFIX)/lib
	install -m 0755 ./build/libcpg.a $(DESTDIR)$(PREFIX)/lib
	install -m 0644 ./build/qt_docs/* $(DESTDIR)$(PREFIX)/share/doc/cad-play-ground
	install -m 0755 ./AUTHORS $(DESTDIR)$(PREFIX)/share/doc/cad-play-ground
	install -m 0644 -d $(DESTDIR)$(PREFIX)/share/man/man1
	install -m 0644 ./docs/ProLitEd/CadPlayG.1 $(DESTDIR)$(PREFIX)/share/man/man1
	gzip -9 $(DESTDIR)$(PREFIX)/share/man/man1/CadPlayG.1
.PHONY : install


uninstall:
	-rm -f $(DESTDIR)$(PREFIX)/bin/CadPlayG
	-rm -rf $(DESTDIR)$(PREFIX)/share/doc/cad-play-ground
	-rm -f $(DESTDIR)$(PREFIX)/share/man/man1/CadPlayG.1.gz
.PHONY : uninstall


help:
	@echo "The following are valid targets for this Makefile:"
	@echo "... all (the default if no target is provided)"
	@echo "      Builds all components of the project. The"
	@echo "      output is hardcoded to ./build directory."
	@echo "... clean"
	@echo "      Removes the results of all target"
	@echo "... distclean"
	@echo "      Same as clean target"
	@echo "... install "
	@echo "      Installs the program on this machine. "
	@echo "      When runned like this:"
	@echo "           make install"
	@echo "      it will use /usr/local as target location."
	@echo "      "
	@echo "      When runned like this:"
	@echo "           make install PREFIX=/a/b/c"
	@echo "      it will use /a/b/c as target location."
	@echo "... uninstall"
	@echo "      Removes the results of install target"
.PHONY : help
